﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;

namespace GAIQ
{
    public static class ListOp
    {
        private static Hashtable Op;
        static ListOp()
        {
            Op = new Hashtable();
            Op.Add("+", new AddOperation());
            Op.Add("-", new SubOperation());
            Op.Add("*", new MulOperation());
            Op.Add("/", new DivOperation());

        }
        public static int getLength() {
            return Op.Keys.Count;
        }

        public static bool isOp(string o)
        {
            if (Op.Contains(o))
                return true;
            return false;
        }

        public static Operation getOp(string o)
        {
            if (!Op.Contains(o))
                throw new Exception("Операция " + o + " не поддерживается"); 
            return (Operation)Op[o];
        }
        public static string[] getSymbols()
        {
            string[] result = new string[Op.Keys.Count];
            IEnumerator e = Op.Keys.GetEnumerator();
            e.Reset(); e.MoveNext();
            for (int i = 0; i < result.Length; ++i)
            {
                result[i] = (string)e.Current;
                e.MoveNext();
            }
            return result;
        }
    }
}
